<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>制作Web页面广告</title>
    <style type="text/css">
      * {
        margin: 0;
        padding: 0;
      }
     /*219970413刘慧*/
      .div1 {
        width: 1000px;
        height: 1000px;
        background-color: rgb(201, 229, 246);
        margin: 0 auto;
        margin-bottom: 20px;
      }
      .div2 {
        width: 1000px;
        height: 1000px;
        background-color: pink;
        margin: 0 auto;
        margin-bottom: 20px;
      }
      .div3 {
        width: 1000px;
        height: 1000px;
        background-color: greenyellow;
        margin: 0 auto;
      }

      /* 对联广告样式 */
      #advertisement1,
      #advertisement2 {
        position: fixed;
        top: 0;
        width: 250px;
        height: 350px;
        background-image: url(images/rio1.jpg);
        background-size: 110% auto;
      }
      #advertisement1 {
        left: 0;
      }
      #advertisement2 {
        right: 0;
      }

      /* 弹窗广告样式 */
      #advertisement3 {
        position: fixed;
        right: 0;
        height: 350px;
        width: 280px;
        background-image: url(images/rio2.jpg);
        /* display: none; */
        background-size: cover;
        /* 按比例缩放以填充元素 */
        /* background-color: #ffffff; */
      }

      /* 关闭按钮图片样式 */
      #left_close,
      #right_close {
        width: 15px;
        height: 15px;
        position: absolute;
        bottom: 0;
        right: 0;
        background-image: url(images/sc.PNG);
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center center;
      }

      #close3 {
        width: 15px;
        height: 15px;
        object-fit: cover;
        position: absolute;
        top: 0;
        right: 0;
        background-image: url(images/sc.PNG);
        background-repeat: no-repeat;
        background-size: cover;
        background-position: center center;
      }
    </style>
  </head>

  <body>
    <div id="advertisement1">
      <div id="left_close"></div>
    </div>
    <div class="div1"></div>
    <div class="div2"></div>
    <div class="div3"></div>
    <div id="advertisement2">
      <div id="right_close"></div>
    </div>
    <div id="advertisement3" style="bottom: -350px">
      <div id="close3"></div>
    </div>
  </body>
  <script type="text/javascript">
    //219970413刘慧
    var left_close = document.querySelector("#left_close");
    var right_close = document.querySelector("#right_close");
    var close3 = document.querySelector("#close3");
    var ad1 = document.getElementById("advertisement1");
    var ad2 = document.getElementById("advertisement2");
    var ad3 = document.getElementById("advertisement3");

    //对联式关闭
    left_close.onclick = function () {
      ad1.style.display = "none";
      ad2.style.display = "none";
    };

    right_close.onclick = function () {
      ad1.style.display = "none";
      ad2.style.display = "none";
    };

    /* 关闭弹窗广告 */
    close3.onclick = function () {
      ad3.style.display = "none";
    };
    //设置定时器
    var virus = setInterval(up, 10);

    function up() {
      var speed = 2;
      var bottom = parseInt(ad3.style.bottom) + speed;
      ad3.style.bottom = bottom + "px";
      if (bottom >= 0) {
        clearInterval(virus); //取消由setInterval()设置的timeout
      }
    }
  </script>
</html>
